package org.example.ttms;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Objects;

public class Main extends Application {

    public static Stage stage;
    public static Scene scene;
    //切换整个页面
    public static void jumpPage(String url) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource(url));
        scene = new Scene(fxmlLoader.load());
        scene.getStylesheets().add(Objects.requireNonNull(Main.class.getResource("/org/example/ttms/css/style.css")).toExternalForm());
        stage.setScene(scene);
    }
    //切换部分页面
    public static void jumpPage2(StackPane stackPane, String url){
        FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource(url));
        stackPane.getChildren().clear();
        try {
            stackPane.getChildren().add(fxmlLoader.load());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    @Override
    public void start(Stage primaryStage) throws Exception {
        stage = primaryStage;
        stage.setTitle("火车票务管理系统");
//        stage.getIcons().add(new Image("C:\\project\\trainTicketManagementSystem\\TTMS\\src\\main\\resources\\org\\example\\ttms\\image\\1.png"));
        stage.getIcons().add(new Image(Main.class.getResourceAsStream("/org/example/ttms/image/1.png")));
        jumpPage("login.fxml");
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}
